<?php
    require_once "config/db.php";

    class MSubMenu extends DB_main
    {
        function return_sub_menu($main_menu_id  = NULL)
        {
            if ($main_menu_id)
            {
                settype($main_menu_id, 'integer');
            }
            $sql = "select id, name from sub_menu
                WHERE main_menu_id = {$main_menu_id} and visible = '1' ORDER BY position";
            if(!$main_menu_id)
            {
                $sql = "select id, name from sub_menu
                WHERE main_menu_id = 1 and visible = '1' ORDER BY position";
            }
            $res = $this->sql($sql);
            return $res;
	}
    }
?>